package com.sky.controller.user;

import com.sky.dto.DishJianDTO;
import com.sky.dto.ShoppingCartDTO;
import com.sky.result.Result;
import com.sky.service.ShoppingCarService;
import com.sky.vo.ShoppingCartVO;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user/shoppingCart")
public class ShoppingCarController {
    @Autowired
    private ShoppingCarService shoppingCarService;
    /**
     * 添加购物车
     * */
    @PostMapping("/add")
    public Result addCart(@RequestBody ShoppingCartDTO dto){
        shoppingCarService.addCart(dto);
        return Result.success();
    }
    /**
     * 查看购物车
     * */
    @GetMapping("/list")
    public Result<List<ShoppingCartVO>>list(){
      List<ShoppingCartVO>list=  shoppingCarService.list();
      return Result.success(list);
    }
    /**
     * 清空购物车
     * */
    @DeleteMapping("/clean")
    public Result clean(){
        shoppingCarService.clean();
        return Result.success();
    }
    /**
     * 购物车减商品
     * */
    @PostMapping("/sub")
    public ShoppingCartVO jian(DishJianDTO dto){
        //shoppingCarService.jian(dto);
        return null;

    }
}
